/**
 * JAVACC DEMO 1.0
 * @copy right dwusoft company All rights reserved. 
 * @Package com.apache.bid.service.plugins  
 */
package com.apache.bid.service.plugins;

import org.apache.log4j.Logger;

import com.apache.api.manager.PluginConnector;
import com.apache.api.vo.ParamsVo;
import com.apache.api.vo.ResultEntity;
import com.apache.bid.common.vo.BidSessionCacheVo;
import com.apache.bid.entity.BidSession;
import com.apache.cache.util.Validator;
import com.apache.database.db.IDao;
import com.apache.database.model.MethodParam;

/**
 * description:  查询单个session对象
 * @author mhguo 创建时间：2016-4-13  
 * 
 */
public class BidSessionEntityPlugin implements PluginConnector {

	private Logger logger = Logger.getLogger(BidSessionEntityPlugin.class);
	private IDao bidSessionDao;

	/**
	 * TODO 简单描述该方法的实现功能（可选）.  
	 * @see com.zbxsoft.api.manager.PluginConnector#execute(com.zbxsoft.api.vo.ParamsVo)  
	 */
	@Override
	public Object execute(ParamsVo vo) throws Exception {
		ResultEntity result = new ResultEntity();
		try {
			result.setResult("true");
			MethodParam param = new MethodParam("ById", "", "", BidSession.class.getName());
			param.setInfoId(String.valueOf(vo.getParams("sessionId")));
			String selectPub = Validator.getDefaultStr(String.valueOf(vo.getParams("selectPub")), "F");
			if (!Validator.isNull(String.valueOf(vo.getParams("sessionId")))) {
				if ("F".equals(selectPub)) {
					BidSession bSession = (BidSession) bidSessionDao.selectById(param);
					result.setEntity(bSession);
				} else {
					param.setKey("ByAllId");
					BidSessionCacheVo scv = (BidSessionCacheVo) bidSessionDao.selectById(param);
					result.setEntity(scv);
				}
				result.setMessage("查询单个BidSession对象成功！");
			} else {
				result.setResult("false");
				result.setMessage("缺少必要的参数，查询单个BidSession对象失败！");
			}
		} catch (Exception e) {
			result.setResult("false");
			logger.error("执行单个BidSession查询失败 ", e);
			result.setMessage("单个BidSession查询失败！");
		}

		return result;
	}

	public void setBidSessionDao(IDao bidSessionDao) {
		this.bidSessionDao = bidSessionDao;
	}

}
